﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SoundManager : MonoBehaviour {

    public AudioSource audioSource;
    public AudioClip[] clips;
    Dictionary<string, AudioClip> audioDictionary = new Dictionary<string, AudioClip>();
    private void Awake()
    {
        foreach (var item in clips)
        {
            audioDictionary.Add(item.name, item);
        }
    }
    // Use this for initialization
    void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}

    public void PlaySound(string soundName)
    {
        if (audioDictionary.ContainsKey(soundName))
        {
            audioSource.PlayOneShot(audioDictionary[soundName]);
        }
    }
}
